package it.polimi.traveldream.beans;

import it.polimi.traveldream.dto.UserDTO;
import it.polimi.traveldream.ejb.UserManager;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name = "registerBean")
@RequestScoped
public class RegisterBean {

	@EJB
	private UserManager userManager;

	private UserDTO user;

	public RegisterBean() {
		this.user = new UserDTO();
	}

	public UserDTO getUser() {
		return this.user;
	}

	public void setUser(UserDTO user) {
		this.user = user;
	}

	public String register() {
		this.userManager.save(this.user);
		return "home?faces-redirect=true";
	}
}
